package com.bwie.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.bwie.pojo.TbRegion;
import com.bwie.service.TbRegionService;
import com.bwie.mapper.TbRegionMapper;
import com.bwie.utils.R;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @author lenovo
 * @description 针对表【tb_region(省市区联动表)】的数据库操作Service实现
 * @createDate 2025-06-22 20:23:08
 */
@Service
public class TbRegionServiceImpl extends ServiceImpl<TbRegionMapper, TbRegion>
        implements TbRegionService {


    @Autowired
    TbRegionMapper tbRegionMapper;

    @Override
    public R getRegionByPid() {

        List<TbRegion> tbRegionList = tbRegionMapper.selectList(
                new QueryWrapper<TbRegion>().lambda().eq(TbRegion::getLevel, 1)
        );

        return R.OK(tbRegionList);
    }

    @Override
    public R getRegionById(Integer id) {

        List<TbRegion> tbRegions = tbRegionMapper.selectList(
                new QueryWrapper<TbRegion>().lambda().eq(TbRegion::getParentId, id)
        );

        return R.OK(tbRegions);
    }
}




